package com.project.tipoff;

import java.util.List;

import com.alibaba.fastjson.JSONArray;
import com.example.zhuzhou.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class PinglunAdapter extends BaseAdapter {
	private List<Pinglun> list;
	private Context context;
	private JSONArray array;

	public PinglunAdapter(Context context, JSONArray array) {
		super();
		this.context = context;
		this.array = array;

	}

	public JSONArray getArray() {
		if (array == null)
			return new JSONArray();
		return array;
	}

	class ViewHold {
		ImageView Touxiang;
		TextView Nickname;
		TextView Time;
		TextView PinglunContent;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHold viewHold = new ViewHold();
		if (convertView == null) {
			LayoutInflater inflater = LayoutInflater.from(context);
			convertView = inflater.inflate(R.layout.tipoff_pinglun_list_show,
					null);

			viewHold.Touxiang = (ImageView) convertView
					.findViewById(R.id.tipoff_pinglun_touxiang);
			viewHold.Nickname = (TextView) convertView
					.findViewById(R.id.tipoff_nickname1);
			viewHold.Time = (TextView) convertView
					.findViewById(R.id.tipoff_time1);
			viewHold.PinglunContent = (TextView) convertView
					.findViewById(R.id.tipoff_content1);

			convertView.setTag(viewHold);
		} else {
			viewHold = (ViewHold) convertView.getTag();
		}

		viewHold.Touxiang.setImageResource(list.get(position).getTouxiang());
		viewHold.Nickname.setText(list.get(position).getNickName());
		viewHold.Time.setText(list.get(position).getTime());
		viewHold.PinglunContent.setText(list.get(position).getPingLun());

		return convertView;
	}

}
